package com.csthink.auditlog.repository;

import com.csthink.auditlog.domain.AuditLog;
import com.csthink.auditlog.domain.ScrollAuditLogs;
import com.csthink.auditlog.dto.AuditLogQueryParamDTO;
import com.csthink.auditlog.dto.PageResultDTO;

import java.io.IOException;
import java.util.List;

/**
 * @author <a href="mailto:security.2009@live.cn">Mars</a>
 * @since 2023-09-12
 */
public interface AuditLogRepository {

    /**
     * Save the Audit Log
     *
     * @param auditLog
     * @return
     * @throws IOException
     */
    AuditLog save(AuditLog auditLog) throws IOException;

    /**
     * Batch save the Audit Log
     *
     * @param auditLogList
     * @return
     * @throws IOException
     */
    List<String> batchSave(List<AuditLog> auditLogList) throws IOException;

    /**
     * find Audit Log by the id
     *
     * @param id
     * @return
     * @throws IOException
     */
    AuditLog findById(String id) throws IOException;

    /**
     * Search Audit Logs under the conditions.
     * order by:
     * 1. createdTime desc;
     * 2. ES's score desc first;
     * So you will get newest, most matched Audit Logs.
     *
     * @param queryParam
     * @return
     * @throws IOException
     */
    PageResultDTO<AuditLog> query(AuditLogQueryParamDTO queryParam) throws IOException;

    ScrollAuditLogs scrollAuditLog(AuditLogQueryParamDTO queryParam) throws IOException;
}
